<template>
  <div>
    <j-modal :visible="visible" :title="`${currentItem.businessName}评标详情`" :footer="null" :width="800"
             :fullscreen="true" @cancel="visible = false">
      <a-row :gutter="20">
        <a-col :span="8">
          <a-card>
            <a-list item-layout="horizontal" :data-source="tenderList">
              <a-list-item slot="renderItem" slot-scope="item, index">
                <a-list-item-meta description="">
                  <a slot="title" :class="[selectTenderId == item.id?'selected':'']" @click="changeTender(item)">{{ item.bidderName }} {{ item.bidderOrgCode }}</a>
                </a-list-item-meta>
              </a-list-item>
            </a-list>
          </a-card>
        </a-col>
        <a-col :span="16">
          <a-list  :grid="{gutter: 16, column: 4}"
                      :data-source="expertList">
            <a-list-item slot="renderItem" slot-scope="item, index">
              <a-list-item-meta description="">
                <a slot="title" :class="[selectExpertId === item.expertId?'selected':'']"
                   @click="changeExpert(item)">{{ item.name }} </a>
              </a-list-item-meta>
            </a-list-item>
          </a-list>
          <template  v-if="currentItem.type == 1">
            <a-tabs v-model="activeKey" type="card">
              <a-tab-pane key="1" tab="综合指标">
              </a-tab-pane>
              <a-tab-pane key="2" tab="技术指标">
              </a-tab-pane>
            </a-tabs>
            <score v-show="activeKey == '1'" :completeFlag="true" ref="score1Ref" :currentItemId="currentItem.id"
                   :entryId="currentItem.businessId" :standardType="'综合指标'" :disabled="true" :expertId="selectExpertId"></score>
            <score v-show="activeKey == '2'" :completeFlag="true" ref="score2Ref" :currentItemId="currentItem.id"
                   :entryId="currentItem.businessId" :standardType="'技术指标'" :disabled="true" :expertId="selectExpertId"></score>
          </template>
          <!-- <a-col v-if="currentItem.type == 1" :span="18">
            {{ reviewItemList }}
          </a-col> -->
          <a-col v-else :span="24">
            <a-table rowKey="id" bordered size="middle" :columns="columns" :dataSource="showList" :pagination="false">
              <div slot="action" slot-scope="text, record">
                <template v-if="record.score < 0">
                  未评分
                </template>
                <template v-else>
                  {{record.score?'符合':'不符合'}}
                </template>

              </div>
            </a-table>
          </a-col>
        </a-col>
      </a-row>
      <!-- 符合性审查当前投标人下的 所有专家的评分记录 -->
      <FhxExpertDetail  v-if="currentItem.type==2"  :bidSectionId="sectionId" :businessId="currentItem.businessId"  />
    </j-modal>

  </div>
</template>

<script>
import { getAction, postAction } from '@api/manage'
import Score from '@views/exPingbiao/review/Score.vue'
import FhxExpertDetail from '@views/exPingbiao/result/FhxExpertDetail'
export default {
  name: 'PingBiaoExpertRecordDetail',
  components: { Score,FhxExpertDetail },
  props: {
    currentItem: {
    },
    sectionId: {},
    columns: {},
    reviewItemList: {},
    tenderList: {}
  },
  data () {
    return {
      selectTenderId: null,
      visible: false,
      expertList: [],
      selectExpertId: null,
      list: [],
      url: {
        queryExpertList: '/exPingbiao/exPingbiaoExpert/queryExpertListBySectionId',
        getPingbiaoRecordListByExpertId: '/exPingbiao/exPingbiaoExpert/getPingbiaoRecordListByExpertId'
      },
      showList: [],
      activeKey: '1'
    }
  },

  computed: {},
  methods: {
    showModal (sectionId) {
      this.visible = true
      this.sectionId = sectionId
      this.selectTenderId = this.tenderList[0].id
      this.queryExpertList()
      this.queryExpertPingbiaoRecord();
    },
    queryExpertPingbiaoRecord () {
      if(this.currentItem.type == 1){
        return;
      }
      this.showList = [];
      let params = {
        tenderListId: this.selectTenderId,
        businessType: this.currentItem.type == 1 ? '评分标准' : '符合性审查项',
        businessId: this.currentItem.id,
        expertId: this.selectExpertId
      }
      getAction(this.url.getPingbiaoRecordListByExpertId, params)
        .then((res) => {
          let list = res.result;
          console.log(this.reviewItemList,list)
          this.reviewItemList.forEach(e=>{
            let item = JSON.parse(JSON.stringify(e))
            let find = list.find(find => find.businessId == e.id)
            item.score = -2;
            if (find) {
              item.score = find.score
            }
            this.showList.push(item)
          });
          console.log(res.result)
        })
        .finally(() => {})
    },
    queryExpertList () {
      getAction(this.url.queryExpertList, { sectionId: this.sectionId })
        .then((res) => {
          this.expertList = res.result
          if (this.expertList && this.expertList.length > 0) {
            this.selectExpertId = this.expertList[0].expertId
          }
        })
        .finally(() => {})
    },
    //选中投标人
    changeTender (item) {
      this.selectTenderId = item.id
      this.queryExpertPingbiaoRecord();
    },
    changeExpert (record) {
      this.selectExpertId = record.expertId
      this.queryExpertPingbiaoRecord();
    }
  },
  created () {
  }
}
</script>

<style scoped>
.selected {
  color: #1890ff;
}
</style>
